
import pytest
from common.recordlog import logs
import os
from conf.setting import DIR_BASE
from common.readyaml import ReadYamlData
from common.generateId import m_id,c_id
import allure

@allure.feature(next(m_id) + '登录baidu')
class TestWebLoginOrder:


    @pytest.mark.parametrize("testcase", ReadYamlData().get_testcase_yaml(os.path.join(DIR_BASE, "testcase", "login_baidu", "baidu_login_by_pwd.yml")))
    @allure.story(next(c_id) + "登录baidu")
    @pytest.mark.run(order=1)
    def test01_web_login_order(self,testcase,get_web_driver):
        print(testcase)
        try:
            # 登录
            logs.info(f"登录功能测试 测试用例名：{testcase["name"]}")
            get_web_driver.page_web_login(username=testcase["username"],pwd=testcase["password"])

            if testcase["expected"] == "登录成功":
                assert get_web_driver.web_login_check() == "验证方式选择"
            else:
                assert testcase["expected"] in get_web_driver.page_web_login_info()

        except Exception as e:
            logs.error(f"测试登录功能异常 异常：{e}")
            # 截图
            get_web_driver.base_get_img()
            # 抛异常
            raise




